close all; clear; clc;
%% 二值化
img = imread("rice.png");
subplot(121);   imshow(img);
[m,n] = size(img);
new_image = zeros(m,n);
thresholdx = 120;
for ii = 1:m
    for jj = 1:n
        if img(ii,jj) > thresholdx
            new_image(ii,jj) = 255;
        else
            new_image(ii,jj) = 0;
        end
    end
end
subplot(122);
imshow(new_image);


